package com.kelvin.oocl.threadLocal;


import com.kelvin.oocl.testTransaction.model.Customer;
import com.kelvin.oocl.testTransaction.tool.DBUtils;

public class ThreadLocalCus {
    private static ThreadLocal<Customer> threadLocal = new ThreadLocal();

    public static void main(String[] args) {
        Customer customer = new Customer(10,"Kelvin","123");
        new Thread("Thread-1") {
            @Override
            public void run() {
                threadLocal.set(customer);
                for (int i = 0; i < 3; i++) {
                    System.out.println(Thread.currentThread().getName() + "-> " + threadLocal.get());
                }
            }
        }.start();
        new Thread("Thread-2") {
            @Override
            public void run() {
                threadLocal.set(customer);
                for (int i = 0; i < 3; i++) {
                    System.out.println(Thread.currentThread().getName() + "-> " + threadLocal.get());
                }
            }
        }.start();
    }
}
